package models

import (
	"github.com/jinzhu/gorm"
)

type ArticleCategory struct {
	//Model
	ID        int    `gorm:"primary_key" json:"id"`
	Title     string `json:"title"`
	Sort      int    `json:"sort"`
	ParentId  int    `json:"parent_id"`
	IsEnabled int   `json:"is_enabled"`

}

func (u ArticleCategory) TableName() string {
	return "article_categories"
}


func GetArticleCategoryAll() ([]*ArticleCategory, error) {
	var articleCategory []*ArticleCategory
	err := DB.Where("is_enabled = ? ", 0).Find(&articleCategory).Error
	
	if err != nil && err != gorm.ErrRecordNotFound {
		return nil, err
	}

	return articleCategory ,err
}
